/// additem,edititem..   (data)

import { FetchFunc } from "../request/http"


export async function getlist(searchText) {

   const result = await FetchFunc("/api/todolist", 'get');


   if (searchText) {

      const searchResult = result.filter(item => item.itemname.indexOf(searchText) != -1)

      return searchResult
   }
   //localStorage.setItem("mylist", JSON.stringify(result));
   return result
}

export async function add(data) {  //restful api
   debugger
   const result = await FetchFunc('/api/todolist', "post", data)

   return result //code, errno

}


export async function edit(data) {
   const result = await FetchFunc('/api/todolist/' + data.id, "put", data)

   return result //code, errno

}

export async function del(id) {
   const result = await FetchFunc('/api/todolist/' + id, "delete")

   return result //code, errno

}
